www.gusucode.com > Java 实现模拟路由器程序 > Java 实现模拟路由器程序\www.gusucode.com\Simple Router\readme.txt

    Simple Routing


1. Compiling the program
------------------------
javac *.java

2. Running the program
----------------------
The program has two components:
1.RouterServer
2.bfnode
3.Command

The following files should be present in the directory before running the programs:
1. Topology Configuration File
2. Router Location file
3. Event File

Starting RouterServer: $java -classpath . RouterServer

Starting bfnode: $java -classpath . bfnode <local-port> <neighbor1-port> <distance1> <neighbor2-port> <distance2> ... <last>
	<local-port>:The UDP listening port number of the node
	<neighbor#-port>:The UDP listening port number of one of the neighboring nodes
	<distance#>:The link distance to the <neighbor1-port>
							 Keep listing the pair of <neighbor-port> and <distance> for all your neighboring nodes
	<last>:Indication of the last node information of the network. Upon the input of the command
				  with this argument, the routing message exchanges among the nodes should kick in
	exit(ctrl-C):Exit the program

Starting Command: $java -classpath . Command -f <ef> -l <rlf> -t <tcf> -o <log> -s
	The default values are:
	<ef>: ef.txt
	<rlf>: rlf.txt
	<tcf>: tcf.txt
	<log>: log.txt

It is advisable to use "-s" option for running Command. If it is not used, it might lead to undesirable results because the Command might request the Routers to display the Routing Tables even before the exchange of Distance Vectors is completed.

3. About the Algorthm
---------------------

1. The Distance Vector Algorithm given in the *2nd edition* of the text book is implemented. So the format of the Routing Tables is according to the Figure 4.7 in the 2nd edition of the text book where:

* There is a row corresponding to each destination in the network
* There is a column corresponding to each neighbor of the given node.
* An entry (i,j) gives the distance to the destination 'i' when the first hop on the path is neighbor 'j'

2. For convenience, infinity is taken as 10000.
The client has an easy-to-use Graphical User Interface (GUI) to the user.

3. The operations performed by the Router for various commands are:

*addRouter: returns true if its id matches (trivial)

*deleteRouter: if the node is a neighbor, removes the corresponding row and column and updates the distance vector. if it is not a neighbor, ignores the command

*update: if the node is not present in the routing table, adds a new row and column corresponding to the node. if the node is present and is a neighbor, it will modify the column corresponding to the node. if the node is present and is not a neighbor, it will add a column.

*packets: return the packets and make packets 0

*display: display the routing table

*route: send the next hop

*step: send the dv to its incoming neighbors

4. Assumptions/Limitations
--------------
1. The algorithm does not implement Poisson Reverse. This might lead to a count-to-infinity problem.
2. After finishing the program, the Routers have to be killed by hand.


5. File Directory
-----------------
bfnode.java - program to get input information 
RouterServer.java - work as a router server
Router.java - the code for Router
RouterThread.java - A thread that listens for packets from other routers
CommandThread.java - a thread that listens for commands from Command program
TopologyFileEntry.java - an entry in the topology file
Topology.java - the initial toplogy
RouterLocationEntry.java - an entry in the Router Location File
RouterLocation.java - the router locations
RoutingTable.java - the routing table
Command.java - the command program
Packet.java - the distance vector packet